import { getHomeOrderData } from '@/api/home'
import { ref } from 'vue'

export default () => {
  // 获取首页统计数量加载
  const getStatisticsQtyLoading = ref(false)

  // 首页统计数据
  const statisticsQty = ref<HomeStatisticsQty>({
    currentMonthFinishOrderQty: 0,
    currentMonthFollowUpCustomerQty: 0,
    exceptionOrderQty: 0,
    lastMonthFinishOrderQty: 0,
    lastMonthFollowUpCustomerQty: 0,
    todayFinishQty: 0,
    todayFollowUpCustomerQty: 0,
    waitCheckFeeQty: 0,
    waitCheckSpareQty: 0,
    waitSettltmentQty: 0,
    yestodayFinishOrderQty: 0,
  })

  /**
   * 获取首页统计数量
   */
  const getStatisticsQty = async () => {
    getStatisticsQtyLoading.value = true
    const res = await getHomeOrderData()
    statisticsQty.value = res.data.data.row
    getStatisticsQtyLoading.value = false
  }

  return {
    statisticsQty,
    getStatisticsQtyLoading,
    getStatisticsQty,
  }
}
